/*
 ============================================================================
 Name		: CBufferManager.h
 Author	  : lin.chaoming
 Version	 : 0.1
 Copyright   : do1
 Description : CCBufferManager declaration
 ============================================================================
 */

#ifndef CBUFFERMANAGER_H
#define CBUFFERMANAGER_H

// INCLUDES
#include <e32std.h>
#include <e32base.h>
#include <EZBufman.h>
// CLASS DECLARATION

/**
 *  CCBufferManager
 * 
 */
class CBufferManager: public CBase, public MEZBufferManager
{
public:
     static CBufferManager* NewLC(const TDesC8& aInput, CBufFlat& aOutput, TInt aBufferSize = 64);
     static CBufferManager* NewL(const TDesC8& aInput, CBufFlat& aOutput, TInt aBufferSize = 64);
     ~CBufferManager();

private:
     CBufferManager(CBufFlat& aOutput);
     void ConstructL(const TDesC8& aInput, TInt aBufferSize);

public: //from MEZBufferManager
     void InitializeL(CEZZStream &aZStream);
     void NeedInputL(CEZZStream &aZStream);
     void NeedOutputL(CEZZStream &aZStream);
     void FinalizeL(CEZZStream &aZStream);

private:
     HBufC8* iInput;
     CBufFlat& iOutput;
     
     TInt iBufferSize;
     
     TUint8* iInputBuffer;
     TUint8* iOutputBuffer;
     
     TPtr8 iInputDescriptor;  // always points to start of the input Buffer
     TPtr8 iOutputDescriptor; // always points to start of the output Buffer

};

#endif // CBUFFERMANAGER_H
